<article class="module width_full">
<header>
    <h3 class="tabs_involved">Permissions Admin</h3>
    <a href='/admin/permissions/advance' >Advance</a>
</header>
    
<?php
echo $this->partial('partials/permissionText.phtml',array(
            'add' => $this->add,
            'delete' => $this->delete
));
?>
    
<div class="tab_container">
    <div id="tab1" class="tab_content">
        <table class="tablesorter" cellspacing="0"> 
        <thead>
            <tr>
                <th class="nobg">Controlador</th>
                <?php foreach ($this->roles as $role): ?>
                    <th ><?php echo $role['role']; ?></th><?php
                endforeach; ?>
            </tr>
        </thead>
        <?php
        $type = "";
        $i=0;
        foreach ($this->controllers as $controller):
            if ($i%2==0){
                $classth = 'class="spec"';
                $classtd = '';
            }else{
                $classth = 'class="specalt"';
                $classtd = 'class="alt"';
            }
            $i++;
            if ($type != $controller['module']): ?>
                <tr>
                    <td colspan="<?php echo count($this->roles) + 1; ?>" >
                        <?php echo $controller['module'] ?>
                    </td>
                </tr>
                <?php
                $type = $controller['module'];
            endif;
            ?>
            <tr>
                <td <?php echo $classth;?>><?php echo $controller['controller']; ?></td>
                <?php
                foreach ($this->roles as $role):
                    $select = "";
                    $found = FALSE;
                    foreach ($this->ALCCount as $acl) {
                        if (($acl['id_role'] == $role['id']) && ($acl['id']) == $controller['id']) {
                            foreach ($this->ControllerCount as $ControllerCount) {
                                if ($controller['id'] == $ControllerCount['id_controller']) {
                                    $dif = $ControllerCount['counController'] - $acl['ACLCount'];
                                    $found = TRUE;
                                }
                            }
                        }
                    }
                    if (($found) && ($dif == 0)) {
                        $img= "icon_check.png";
                        $option = 0;
                    } else {
                        if ($found) {
                            $img = "icon_light_check.png";
                            $option = 0;
                        } else {
                            $img = "icon_none.png";
                            $option = 1;
                        }
                    } ?>
                    <td <?php echo $classtd;?>>
                        <div id="<?= $controller['id'] . "-" . $role['id']; ?>" name="<?= $controller['id'] . "-" . $role['id']; ?>">
                            <img src="<?= $this->theme("/img/" . $img,true,'admin'); ?>" onclick='guardarPermisoControlador("<?= $controller['id'] . "-" . $role['id']; ?>",<?= $option; ?>,"<?= $this->theme('',true,'admin'); ?>")' />
                        </div>
                    </td>
                <?php endforeach; ?>
            </tr>
            <?php endforeach; ?>
    </table>
                
</article>